<?php
include "init.php";

$act = $_POST ['act'];
if ($act=='add') {	
    
	$record = array(
		'title'			=>$_POST ['title'],
		'content'		=>$_POST ['content'],
		'add_time'		=>time(),
		'state'			=>$_POST ['state']
	);
	$id = $db->autoExecute("$_SC[tablepre]notice",$record);
	header("Location: notice.php");
}

if ($act=='edit'){	
    
	$id = $_POST ['id'];
	$record = array(
		'title'			=>$_POST ['title'],
		'content'		=>$_POST ['content'],
		'state'			=>$_POST ['state']
	);
	 $db->autoExecute("$_SC[tablepre]notice",$record, 'UPDATE' , 'id='.$id);
	 header("Location: notice.php");
}

if ($act=='delete') {	
    
	$id = $_POST ['id'];
	$db->delete("$_SC[tablepre]notice",'id in('.$id.')');
	exit();
}

?>